package com.shiku.im.push.service;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import org.springframework.core.io.ClassPathResource;

public class GooglePushUtil extends PushServiceUtils{
	
	public InputStream getJson() throws FileNotFoundException{
		log.info("getJSON :{}",pushConfig.getFCM_keyJson().startsWith("classpath:"));
		try {
			if(pushConfig.getFCM_keyJson().startsWith("classpath:")) {
				ClassPathResource resource = new ClassPathResource(pushConfig.getFCM_keyJson());
				String path = resource.getClassLoader().getResource(pushConfig.getFCM_keyJson().replace("classpath:", "")).getPath();
				pushConfig.setFCM_keyJson(path);
				InputStream stream = this.getClass().getResourceAsStream(pushConfig.getFCM_keyJson());
				return this.getClass().getResourceAsStream(pushConfig.getFCM_keyJson());
			}
			FileInputStream fileInputStream = new FileInputStream(new File(pushConfig.getFCM_keyJson()));
			System.out.println("file"+fileInputStream);
			return new FileInputStream(new File(pushConfig.getFCM_keyJson()));
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage(),e);
		}
		return new FileInputStream(new File(""));
	}
}
